"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2024/12/21
"""
import numpy as np

array = np.arange(10)
print(array)

print(array.shape)

array.shape = 2, 5
print(array)  # 2 row   5 colum

array = array.reshape(1, 10)
print(array)

# array = array.reshape(3, 4)

array = array[np.newaxis, :]
print(array.shape)

array = array[:, np.newaxis, np.newaxis]
print(array.shape)

array2 = array.squeeze()  # 压缩
print(array2)
print(array2.shape)

array2.shape = 2, 5
print(array2)

array2 = array2.transpose()
print(array2)

array2 = array2.T
print(array2)

# 数组的连接
a = np.array([[13, 45, 78], [23, 56, 89]])

b = np.array([[123, 456, 789], [321, 654, 987]])

c = np.concatenate((a, b))
print(c)  # default  axis = 0    竖着

c1 = np.concatenate((a, b), axis=1)
print(c1)  # 横着
print(c1.shape)

print(np.vstack((a, b)))
print(np.hstack((a, b)))

print(a.flatten())  # 拉平
print(a.ravel())  # 拉平
